package com.common.loadbalance.impl;


import com.common.loadbalance.CommonLoadBalance;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Random;

/**
 * @author Zixiang Hu
 * @description 随机负载均衡
 * @create 2021-03-03-14:50
 */
public class RandomLoadBalance implements CommonLoadBalance {

    @Override
    public String getServerAddr(List<String> servers) {
        int idx = new Random().nextInt(servers.size());
        return servers.get(idx);
    }
}
